package com.app.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import com.app.common.Result;
import com.app.common.SystemConfig;
import com.app.mapper.AdminHomepageMapper;
import com.app.mapper.IntegralOrderMapper;
import com.app.mapper.OrderMapper;
import com.app.mapper.UserMapper;
import com.app.model.*;
import com.app.service.*;
import com.app.utils.CommonHelp;
import com.app.vo.Top10VO;
import com.app.vo.TurnoverTrendVo;
import com.app.vo.ValueAndDataVo;
import com.app.vo.VoucherIntegralRecordVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.TimeUnit;

@Service
public class AdminHomepageServiceImpl implements AdminHomepageService {
    @Autowired
    public UserService userService;
    @Autowired
    public OrderService orderService;
    @Autowired
    public BusinessSettledService businessSettledService;
    @Autowired
    public BusinessService businessService;
    @Autowired
    public AdminHomepageMapper adminHomepageMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private IntegralOrderMapper integralOrderMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private SystemConfigService systemConfigService;

    /**
     * 生成在tm之后指定月份的Timestamp对象。
     *
     * @param beforeOrAfter
     * @param month
     * @param tm
     * @return
     */
    public static Timestamp getBeforeOrAfterTimestamp(Boolean beforeOrAfter, int month, Timestamp tm) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(tm);

        if (beforeOrAfter) { // before
            calendar.add(Calendar.MONTH, -month);
        } else { // after
            calendar.add(Calendar.MONTH, month);
        }

        return new Timestamp(calendar.getTimeInMillis());
    }

    /**
     * 初始话value数组，并给天数赋值
     *
     * @param value
     * @param day
     */
    private static void initialization(ArrayList<Double> value, ArrayList<String> day) {
        for (int i = 1; i <= 30; i++) {
            value.add(0.0);
            day.add(DateUtil.formatDate(DateUtil.offsetDay(new Date(), -i)));
        }
    }

    /**
     * 统计近一周登录的用户益联券消费情况
     *
     * @return VALUE  data列表
     */
    @Override
    public Result<Object> voucherConsumption(Timestamp beginTime, Timestamp endTime, AdminUserModel user) {
        if ((beginTime == null) && (endTime == null)) {
            endTime = CommonHelp.getNowTimestamp();
            beginTime = CommonHelp.getBeforeOrAfterTimestamp(true, 604800, endTime);
        }
        List<JSONObject> userModelList = userService.userConsumptionVoucherStatistics(user);
        if (userModelList.isEmpty()) {
            return Result.success(new ArrayList<>());
        }
        ArrayList<Double> value = new ArrayList<>();
        ArrayList<String> data = new ArrayList<>();
        for (JSONObject m : userModelList
        ) {
            value.add(m.getDouble("count"));
            data.add(m.getStr("date"));
        }
        ValueAndDataVo valueAndDataVo = new ValueAndDataVo();
        valueAndDataVo.setValue(value);
        valueAndDataVo.setData(data);
        return Result.success(valueAndDataVo);
    }

    /**
     * 近三十天推广情况分析
     *
     * @param user
     * @return
     */
    @Override
    public Result<Object> Promotion(AdminUserModel user) {
        Timestamp endTime = CommonHelp.getNowTimestamp();
        Timestamp beginTime = getBeforeOrAfterTimestamp(true, 1, endTime);
        Integer roleId = user.getRoleId();
        QueryWrapper<UserModel> wrapper = new QueryWrapper<UserModel>();
        if(roleId==3)
        {
            wrapper.select("create_time")
                    .between("create_time", beginTime, endTime)
                    .eq("city_id", user.getAreaId())
                    .orderByDesc("create_time");
        } else if (roleId==4) {
            wrapper.select("create_time")
                    .between("create_time", beginTime, endTime)
                    .eq( "area_id", user.getAreaId())
                    .orderByDesc("create_time");
        }
        List<UserModel> userModelList = userService.list(wrapper);
        ArrayList<Double> value = new ArrayList<>();
        ArrayList<String> data = new ArrayList<>();
        initialization(value, data);
        for (UserModel userModel : userModelList) {
            // 获取当前时间的时间戳
            long currentTimeMillis = System.currentTimeMillis();
            // 获取用户创建时间的时间戳
            long userCreateTimeMillis = userModel.getCreateTime().toInstant().toEpochMilli();
            // 计算用户创建时间距当前时间的天数
            long daysAgo = TimeUnit.MILLISECONDS.toDays(currentTimeMillis - userCreateTimeMillis);
            // 如果用户创建时间在30天内
            if (daysAgo >= 0 && daysAgo < 30) {
                // 计算距离数组结尾的索引
                int index = (int) (29 - daysAgo);
                // 确保索引在数组范围内
                if (index >= 0 && index < value.size()) {
                    // 更新数组中对应索引的值
                    if (value.get(index) != null) {
                        value.set(index, value.get(index) + 1);
                    } else {
                        value.set(index, 1.0);
                    }
                }
            }
        }
        ValueAndDataVo valueAndDataVo = new ValueAndDataVo();
        valueAndDataVo.setValue(value);
        valueAndDataVo.setData(data);
        return Result.success(valueAndDataVo);
    }

    /**
     * 商家top10
     *
     * @param user
     * @return
     */
    @Override
    public Result<Object> top10(AdminUserModel user) {
        Timestamp endTime = CommonHelp.getNowTimestamp();
        Timestamp beginTime = getBeforeOrAfterTimestamp(true, 1, endTime);
        List<Top10VO> top10VOList = adminHomepageMapper.search(beginTime, endTime, user);
        return Result.success(top10VOList);
    }

    /**
     * 营业额走势
     * * 分两种：传商家id的就差指定商家的营业额走势
     * *        不传商家id就查所有商家营业额的总和的走势
     *
     * @param user
     * @param type
     * @return
     */
    @Override
    public TurnoverTrendVo turnoverTrend(AdminUserModel user, Integer type) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        List<TurnoverTrendVo> trend = new ArrayList<>();
//        if (type == 1) {
//            trend = adminHomepageMapper.turnoverTrendByDay(businessId, areaId, cityId);
//        } else if (type == 2) {
        trend = adminHomepageMapper.turnoverTrendByWeek(businessId, areaId, cityId);
//        } else if (type == 3) {
//            trend = adminHomepageMapper.turnoverTrendByMonth(businessId, areaId, cityId);
//        } else if (type == 4) {
//            trend = adminHomepageMapper.turnoverTrendByYear(businessId, areaId, cityId);
//        }
        return getStatisticsVo(trend);
    }


    /**
     * 抽层流水走势
     *
     * @param user
     * @param type
     * @return
     */
    @Override
    public TurnoverTrendVo businessTurnover(AdminUserModel user, Integer type) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        List<TurnoverTrendVo> trend = new ArrayList<>();

        trend = adminHomepageMapper.businessTrendByMonth(businessId, areaId, cityId);

//        else if (type == 4) {
//            trend = adminHomepageMapper.businessTrendByYear(businessId, areaId, cityId);
//        }
        return getStatisticsVo(trend);
    }

    /**
     * 构建返回值
     *
     * @param jsonObjectList
     * @return
     */
    @NotNull
    private TurnoverTrendVo getTurnoverTrendVo(List<JSONObject> jsonObjectList) {
        ArrayList<String> xdata = new ArrayList<>();
        ArrayList<String> turnoverData = new ArrayList<>();
        ArrayList<String> orderCountData = new ArrayList<>();
        for (JSONObject m : jsonObjectList) {
            xdata.add(m.getStr("xdata"));
            turnoverData.add(m.getStr("turnoverData"));
            orderCountData.add(m.getStr("orderCountData"));
        }
        TurnoverTrendVo vo = new TurnoverTrendVo();
//        vo.setXdata(xdata);
//        vo.setTurnoverData(turnoverData);
//        vo.setOrderCountData(orderCountData);
        return vo;
    }

    /**
     * 构建部分SQL查询语句
     *
     * @param user
     * @param type
     * @return
     */
    @NotNull
    private Map<String, Object> getStringObjectMap(AdminUserModel user, Integer type) {
        Integer cityAreaId = user.getAreaId();
        String cityArea = null;
        if (user.getRoleId() != null && user.getRoleId() == 3) {
            cityArea = "city_id";
        } else if (user.getRoleId() != null && user.getRoleId() == 4) {
            cityArea = "area_id";
        }
        String dateCondition = null;
        String groupBy = null;
        if (type == 1) {
            dateCondition = "o.create_time >= CURDATE() AND o.create_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)";
            groupBy = "HOUR(o.create_time), DATE(o.create_time)";
        } else if (type == 2) {
            dateCondition = "o.create_time >= CURDATE() - INTERVAL 7 DAY";
            groupBy = "DATE(o.create_time)";
        } else if (type == 3) {
            dateCondition = "o.create_time >= CURDATE() - INTERVAL 30 DAY";
            groupBy = "DATE(o.create_time)";
        } else if (type == 4) {
            dateCondition = "o.create_time >= CURDATE() - INTERVAL 1 YEAR";
            groupBy = "YEAR(o.create_time), MONTH(o.create_time)";
        }
        // 将cityArea传递给SQL查询
        Map<String, Object> params = new HashMap<>();
        params.put("cityArea", cityArea);
        // 将dateCondition和groupBy传递给SQL查询
        params.put("dateCondition", dateCondition);
        params.put("groupBy", groupBy);
        params.put("cityAreaId", cityAreaId);
        return params;
    }


    public Integer getRate(){
        SystemConfig systemConfig = systemConfigService.getById(1);
        Integer rate = Integer.valueOf(systemConfig.getValue());
        return rate;
    }


    /**
     * 财务报表
     *
     * @param user
     * @param beginTime
     * @param endTime
     * @param area
     * @return
     */
    @Override
    public Result financialStatements(AdminUserModel user, String beginTime, String endTime, Integer area) {
        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", area);
        //平台发放优惠券总金额统计
        Double statisticsOnTotalAmountCouponsIssuedByPlatform = adminHomepageMapper.statisticsOnTotalAmountCouponsIssuedByPlatform(area, user, beginTime, endTime);
        //总抽水
        Double totalPumping = adminHomepageMapper.totalPumping(area, user, beginTime, endTime);
        //会员开通金额
        Double vipAmount = adminHomepageMapper.vipAmount(area, user, beginTime, endTime);
        //会员充值金额
        Double memberRechargeAmount = adminHomepageMapper.memberRechargeAmount(area, user, beginTime, endTime);
        //总流转
        Double totalCirculation = adminHomepageMapper.totalCirculation(area, user, beginTime, endTime);


        Double points=adminHomepageMapper.totalPoints(area, user, beginTime, endTime);

        Map<String,Object> response=new HashMap<>();
        response.put("statisticsOnTotalAmountCouponsIssuedByPlatform",statisticsOnTotalAmountCouponsIssuedByPlatform);
        response.put("totalPumping",totalPumping);
        response.put("vipAmount",vipAmount);
        response.put("totalCirculation",Math.abs(totalCirculation));
        response.put("totalPoints",points);
        response.put("rechargeAmount",memberRechargeAmount);
        return Result.success(response);
    }

    /**
     * 管理后天订单统计
     *
     * @param user
     * @return
     */
    @Override
    public Object goodsOrdernews(AdminUserModel user) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        JSONObject jsonObject = adminHomepageMapper.goodsOrdernews(businessId, cityId, areaId);
        String count1 = jsonObject.get("count1").toString();
        String sum1 = jsonObject.get("sum1").toString();
        String return1 = "总营业额：" + sum1 + "" + "总销售量：" + count1;

        return Result.success(jsonObject);
    }

    /**
     * 活动订单后台管理
     *
     * @param user
     * @return
     */
    @Override
    public Object activityOrderNews(AdminUserModel user) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        JSONObject jsonObject = adminHomepageMapper.activityOrderNews(businessId, cityId, areaId);
        String count1 = jsonObject.get("count1")==null?jsonObject.get("count1").toString():"0";
        String sum1 = jsonObject.get("sum1")==null?jsonObject.get("sum1").toString():"0";
        String return1 = "总营业额：" + sum1 + "   总销售量" + count1;
        return Result.success(return1);
    }

    @Override
    public Object vipNews(AdminUserModel user) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        JSONObject jsonObject = adminHomepageMapper.vipNews(businessId, cityId, areaId);
        String count1 = jsonObject.get("count1").toString();
        String return1 = "总开通人数：" + count1;
        return Result.success(return1);
    }

    /**
     * 用户管理表的统计查询
     *
     * @param user
     * @param ifVip
     * @return
     */
    @Override
    public Object userNews(AdminUserModel user, Integer ifVip) {
        Integer businessId = null;
        Integer areaId = null;
        Integer cityId = null;
        if (user.getRoleId() == 2) {
            businessId = user.getBusinessId();
        }
        if (user.getRoleId() == 3) {
            cityId = user.getAreaId();
        }
        if (user.getRoleId() == 4) {
            areaId = user.getAreaId();
        }
        JSONObject jsonObject = adminHomepageMapper.userNews(businessId, cityId, areaId, ifVip);
        String count1 = jsonObject.get("count1").toString();
        String return1 = "用户总数：" + count1;
        return Result.success(return1);
    }

    /**
     * 凭证详细信息合计
     *
     * @param user      用户
     * @param endTime   结束时间
     * @param areaId    区域id
     * @param beginTime 开始时间
     * @param page      第页
     * @param limit     限制
     * @return {@link Object}
     */
    @Override
    public Object totalVoucherDetails(AdminUserModel user, String beginTime, String endTime, Integer areaId,Integer page,Integer limit) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        Page<VoucherRecordModel> recordModelPage=new Page<>(page,limit);
        IPage<VoucherRecordModel> voucherRecordModelIPage=this.adminHomepageMapper.statisticsOnTotalAmountCouponsIssuedByPlatformList(recordModelPage,areaId, user, beginTime, endTime);
        return voucherRecordModelIPage;
    }

   @Override
    public Object totalCirculation(AdminUserModel user, String beginTime, String endTime, Integer areaId,Integer page,Integer limit) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        Page<VoucherRecordModel> recordModelPage=new Page<>(page,limit);
        IPage<VoucherRecordModel> voucherRecordModelIPage=this.adminHomepageMapper.totalCirculationDetails(recordModelPage,areaId, user, beginTime, endTime);
        return voucherRecordModelIPage;
    }

    /**
     * 消费者数据
     *
     * @param user      用户
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param areaId    区域id
     * @return {@link Object }
     */
    @Override
    public Object consumerData(AdminUserModel user, String startTime, String endTime, Integer areaId) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", startTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        //消费多少送多少总流转券量
        Double howMuchDoYouSpendAndHowMuchDoYouSend = adminHomepageMapper.howMuchDoYouSpendAndHowMuchDoYouSend(startTime, endTime);
        //消费多少送多少商家券量
        Double howMuchDoYouSpendAndHowMuchPartner = adminHomepageMapper.howMuchDoYouSpendAndHowMuchPartner(startTime, endTime);
        //消费多少送多少区代券量
        Double districtCouponVolume = adminHomepageMapper.districtCouponVolume(startTime, endTime);
        //消费多少送多少平台券量
        Double platformVoucherQuantity = adminHomepageMapper.platformVoucherQuantity(startTime, endTime);

        Map<String,Object> response=new HashMap<>();
        response.put("howMuchDoYouSpendAndHowMuchDoYouSend",Math.abs(howMuchDoYouSpendAndHowMuchDoYouSend));
        response.put("howMuchDoYouSpendAndHowMuchPartner",howMuchDoYouSpendAndHowMuchPartner);
        response.put("districtCouponVolume",districtCouponVolume);
        response.put("platformVoucherQuantity",platformVoucherQuantity);
        return response;
    }

    @Override
    public Object transferData(AdminUserModel user, String startTime, String endTime, Integer areaId) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", startTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        //总流转券量
        Double transferDataTotalAmountCirculatingCoupons = adminHomepageMapper.transferDataTotalAmountCirculatingCoupons(startTime, endTime);
        //好友收到券量
        Double amountCouponsReceivedByFriends = adminHomepageMapper.amountCouponsReceivedByFriends(startTime, endTime);
        //转账手续费
        Double transferFee = adminHomepageMapper.transferFee(startTime, endTime);
        //抽成
        Map<String,Object> draw = adminHomepageMapper.draw(startTime, endTime);
        Map<String,Object> response=new HashMap<>();
        response.put("transferDataTotalAmountCirculatingCoupons",Math.abs(transferDataTotalAmountCirculatingCoupons));
        response.put("amountCouponsReceivedByFriends",amountCouponsReceivedByFriends);
        response.put("transferFee",transferFee);
        response.put("draw",draw);
        return response;
    }

    @Override
    public Object transferDataList(Integer type,Integer page,Integer limit,AdminUserModel user, String startTime, String endTime, Integer areaId) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", startTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        Object list=null;
        Page p=new Page(page,limit);
        switch (type)
        {
            case 1:
                list=adminHomepageMapper.transferDataTotalAmountCirculatingCouponsList(p,startTime, endTime);
                break;
            case 2:
                list=adminHomepageMapper.amountCouponsReceivedByFriendsList(p,startTime, endTime);
                break;
            case 3:
                list=adminHomepageMapper.transferFeeList(p,startTime, endTime);
                break;
            case 4:
            case 5:
            case 6:
                list=adminHomepageMapper.drawList(p,startTime, endTime);

        }
        return list;
    }

    /**
     * 充值金额列表
     *
     * @param mobile    移动电话
     * @param page      第页
     * @param limit     限制
     * @param user      用户
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return {@link Object}
     */
    @Override
    public Object rechargeAmountList(String mobile, Integer page, Integer limit, AdminUserModel user, String startTime, String endTime) {
        Page p=new Page(page,limit);

        return this.adminHomepageMapper.rechargeAmountList(p,mobile,user,startTime,endTime);
    }

    @Override
    public Object consumerDataList(Integer page,Integer limit,AdminUserModel user, String startTime, String endTime, Integer areaId,Integer type) {
        Object list=null;
        Page p=new Page(page,limit);
        switch (type)
        {
            case 1:
                list=adminHomepageMapper.howMuchDoYouSpendAndHowMuchDoYouSendList(p,startTime, endTime);
                break;
            case 2:
                list=adminHomepageMapper.howMuchDoYouSpendAndHowMuchPartnerList(p,startTime, endTime);
                break;
            case 3:
                list=adminHomepageMapper.districtCouponVolumeList(p,startTime, endTime);
                break;
            case 4:
                list=adminHomepageMapper.platformVoucherQuantityList(p,startTime, endTime);

        }
        return list;
    }


    @Override
    public Object totalPointsDetails(AdminUserModel user, String beginTime, String endTime, Integer areaId,Integer page,Integer limit) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        Page<IntegralRecordModel> recordModelPage=new Page<>(page,limit);
        IPage<IntegralRecordModel> voucherRecordModelIPage=this.adminHomepageMapper.totalPointsDetails(recordModelPage,areaId, user, beginTime, endTime);
        return voucherRecordModelIPage;
    }

    @Autowired
    private PayService payService;

    @Override
    public Object memberOpeningAmount(AdminUserModel user, String beginTime, String endTime, Integer areaId,Integer page,Integer limit) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", areaId);

        IPage<PayModel> voucherRecordModelIPage=this.payService.getVipListByPage(page,limit, beginTime, endTime, areaId, null);
        return voucherRecordModelIPage;
    }

    @Override
    public Object totalPumpingDetails(AdminUserModel user, String beginTime, String endTime, Integer areaId,Integer page,Integer limit) {

        Map<String, Object> params = new HashMap<>();
        params.put("user", user);
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("area", areaId);
        return   adminHomepageMapper.drawRecord(areaId, user, beginTime, endTime);
    }



    /**
     * 商家们进三十天益联券的总收入情况、要是传了商家id那就是当前商家进三十天的益联券收入情况
     *
     * @param id
     * @param user
     * @return
     */
    @Override
    public Result<Object> voucherIncome(Integer id, AdminUserModel user) {
        Timestamp endTime = CommonHelp.getNowTimestamp();
        Timestamp beginTime = getBeforeOrAfterTimestamp(true, 1, endTime);
        ArrayList<String> day = new ArrayList<>();
        ArrayList<Double> value = new ArrayList<>();
        initialization(value, day);
        List<OrderModel> orderModelList = orderMapper.voucherIncome(id, user, beginTime.toString(), endTime.toString());
        for (OrderModel orderModel : orderModelList) {
            int minuteDec = CommonHelp.getMinuteDec(orderModel.getCreateTime().toString());
            int index = 30 - (minuteDec / 60 / 24) - 1;
            if (value.get(index) != null) {
                value.set(index, value.get(index) + 1);
            } else {
                value.set(index, 1.0);
            }
        }
        ValueAndDataVo valueAndDataVo = new ValueAndDataVo();
        valueAndDataVo.setData(day);
        valueAndDataVo.setValue(value);
        return Result.success(valueAndDataVo);
    }


    private TurnoverTrendVo getStatisticsVo(List<TurnoverTrendVo> vos) {
        int size = vos.size();
        String[] timeArray = new String[size];
        Integer[] countArray = new Integer[size];
        Double[] amountArray = new Double[size];
        for (int i = 0; i < size; i++) {
            timeArray[i] = vos.get(i).getName();
            countArray[i] = vos.get(i).getCount();
            amountArray[i] = vos.get(i).getAmount();
        }
        TurnoverTrendVo vo = new TurnoverTrendVo();
        vo.setXData(timeArray);
        vo.setLyData(countArray);
        vo.setRyData(amountArray);
        return vo;
    }
}
